package com.xique.park.service.biz.service.impl;

import com.xique.common.core.domain.R;
import com.xique.common.core.utils.OrikaUtil;
import com.xique.park.api.dto.ParkingOrderDTO;
import com.xique.park.bean.domain.ParkingOrderOn;
import com.xique.park.service.biz.service.IParkingOrderBizService;
import com.xique.park.service.service.IParkingOrderOnService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author shd
 * @create 2022/1/12 10:39
 */
@Service
public class ParkingOrderBizServiceImpl implements IParkingOrderBizService {

    @Autowired
    private IParkingOrderOnService parkingOrderOnService;

    @Override
    public R<ParkingOrderDTO> getParkingOrder(String plate) {
        ParkingOrderOn search = new ParkingOrderOn();
        search.setPlate(plate);
        List<ParkingOrderOn> list = parkingOrderOnService.selectParkingOrderOnList(search);
        if (CollectionUtils.isEmpty(list)) {
            return R.fail("未找到对应订单");
        }
        return R.ok(OrikaUtil.convert(list.get(0), ParkingOrderDTO.class));
    }
}
